package com.iscas.tech.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.iscas.tech.entity.AtMdbusyValue;
import com.iscas.tech.mapper.AtMdbusyValueMapper;
import com.iscas.tech.param.AtMdbusyValuePageParam;
import com.iscas.tech.service.AtMdbusyValueService;
import com.iscas.tech.vo.AtMdbusyValueQueryVo;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.pagination.PageUtil;
import io.geekidea.springbootplus.framework.pagination.Paging;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 模块业务值对应表 服务实现类
 *
 * @author yangyi
 * @since 2020-10-26
 */
@Slf4j
@Service
public class AtMdbusyValueServiceImpl extends BaseServiceImpl<AtMdbusyValueMapper, AtMdbusyValue> implements AtMdbusyValueService {

    @Autowired
    private AtMdbusyValueMapper atMdbusyValueMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean saveAtMdbusyValue(AtMdbusyValue atMdbusyValue) throws Exception {
        return super.save(atMdbusyValue);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateAtMdbusyValue(AtMdbusyValue atMdbusyValue) throws Exception {
        return super.updateById(atMdbusyValue);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteAtMdbusyValue(Long id) throws Exception {
        return super.removeById(id);
    }

    @Override
    public Paging<AtMdbusyValueQueryVo> getAtMdbusyValuePageList(AtMdbusyValuePageParam atMdbusyValuePageParam) throws Exception {
        Page page = PageUtil.getPage(atMdbusyValuePageParam, OrderItem.desc(getLambdaColumn(AtMdbusyValue::getCreatetime)));
        IPage<AtMdbusyValueQueryVo> iPage = atMdbusyValueMapper.getAtMdbusyValuePageList(page, atMdbusyValuePageParam);
        return new Paging(iPage);
    }

    @Override
    public void deleteByBsId(Long bsId, Integer mdType) throws Exception {
        atMdbusyValueMapper.deleteByBsId(bsId, mdType);
    }

}
